<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
        {{count}}
        {{age}}
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script src="https://unpkg.com/vuex@3.1.3/dist/vuex.js"></script>
    <script>
      var store = new Vuex.Store({
        state:{
            count:0,
            age:18
        }
      });
      var vm = new Vue({
        store,
        el:'#app',
        computed:{
            //用于把仓库里的状态映射为Vue实例中的计算属性
            ...Vuex.mapState(['count','age'])
            /* 
            {
             count(){
                return this.$store.state.count;
             },
             age(){
                return this.$store.state.age;
             }
            }
            */
        }
      });
    </script>
  </body>
</html>